<?php
 include_once 'php/connection.php'; 
 include_once 'header.php';
 if(isset($_GET['id']))
 {
   $delete="delete from images where id='$_GET[id]'";
   if(!mysql_query($delete))
   {
   echo mysql_error();
   }
   else
   {
   unlink('../src/imgs/thumbnail_'.$_GET['id'].'.jpg');
   unlink('../src/imgs/image_'.$_GET['id'].'.jpg');
   ob_start();
   header("location:".$_SERVER["PHP_SELF"]);
   }
    
 }
 else
 {
 
 $sql="select * from images order by id desc";
 if(!$res=mysql_query($sql))
 {
  echo mysql_error();
 }
 else
{ 
?>
<table align="center" width="430" id="tableadmin">
<tr>
<th>
Title
</th>
<th>
Image
</th>
<th>
Delete
</th>
</tr>
  <?
while($row = mysql_fetch_object($res))
{?>
<tr>
<td>
<?=$row->title?>
</td>
<td>
<img src="../src/imgs/thumbnail_<?=$row->id?>.jpg" />
</td>
<td>
<a href="manageimages.php?id=<?=$row->id?>"
			onclick='return confirm("are you sure want to delete");'><img
			src="assets/imgs/delete.png" border='0' /></a>
</td>
</tr>
<?}
}
}?>
</table>